package board.renders.basics;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import board.pieces.Piece;
import board.renders.adapters.OccupantRenderAdapter;
/** Render Circles for all occupants with no other renders set.  
 *  The occupant will be GRAY if it does not implement piece, 
 *  otherwise it will have the color set by the Piece.  
 * 
 *  This is the default render for GridPane.  
 * 
 * @author R.Wisniewski1101
 */
public class BasicOccupantRender extends OccupantRenderAdapter<Object> {
	@Override
	public Image getImage(Object occupant, int width, int height) {
		Image image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		Graphics draw = image.getGraphics();
		if(occupant instanceof Piece)
			draw.setColor(((Piece)occupant).getColor());
		else
			draw.setColor(Color.GRAY);
		draw.fillOval(0, 0, width - 1, height - 1);
		return image;
	}
}
